home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / UCB Logo 3.0 / logolib / foreach < prev    next >
Encoding:
Text File  |  1992-10-12  |  575 b   |  20 lines  |  [TEXT/JV01]

  1. .macro foreach [:foreach.inputs] 2
  2. catch "foreach.catchtag ~
  3.       [op foreach.done runresult ~
  4.         [foreach1 bl :foreach.inputs last :foreach.inputs 1]]
  5. op []
  6. end
  7.  
  8. to foreach1 :template.lists :foreach.template :template.number
  9. if emptyp first :template.lists [throw "foreach.catchtag]
  10. apply :foreach.template firsts :template.lists
  11. .maybeoutput foreach1 bfs :template.lists :foreach.template :template.number+1
  12. end
  13.  
  14. to foreach.done :foreach.result
  15. if emptyp :foreach.result [op [stop]]
  16. op list "output quoted first :foreach.result
  17. end
  18.  
  19. bury [foreach foreach1 foreach.done]
  20.